#pragma once

#include "../DirectXApp/DirectXApp.h"

#include <LightHelper.h>

#include <DirectXMath.h>

class ModelObject;
class EffectsManager;
class InputLayoutsManager;

namespace Rasterizer
{
	enum TYPE
	{
		WIREFRAME = 0,
		SOLID
	};
}

class Application :
	public DirectXApp
{
public:
	Application(HINSTANCE instance);
	~Application(void);

	virtual bool Init();

	virtual void OnResize();
	virtual void Update();
	virtual void Draw();

protected:

	virtual void OnMouseDown	(WPARAM btnState, int x, int y) override;
	virtual void OnMouseUp		(WPARAM btnState, int x, int y)	override;
	virtual void OnMouseMove	(WPARAM btnState, int x, int y) override;
	virtual void OnMouseWheel	(WPARAM btnState, int x, int y) override;

	virtual void OnKeyUp		(WPARAM btnState) override; 
	virtual void OnKeyDown		(WPARAM btnState) override;

private:
	void DestroyObjects();
	void CreateObject(UINT id);
	void CreateLights();
	void CreateEffects();
	void BuildGeometryBuffers();
	void BuildVertexLayout();


private:
	ID3D11RasterizerState*			m_WireframeRS;
	ID3D11RasterizerState*			m_SolidRS;

	ID3D11Buffer*					m_VerticesBuffer;
	ID3D11Buffer*					m_IndicesBuffer;


	DirectX::XMFLOAT3				m_EyePos;
	DirectX::XMFLOAT4X4				m_View;
	DirectX::XMFLOAT4X4				m_Proj;

	Rasterizer::TYPE				m_Rasterizer;

	EffectsManager*					m_EffectsManager;
	InputLayoutsManager*			m_InputLayoutsManager;

	std::vector<ModelObject*>		m_ModelObjects;

	POINT							m_MousePos;
	POINT							m_LastPos;

	Lights::DirectionalLight		m_Light;

	bool							m_MouseDown;

	float							m_Theta;
	float							m_Phi;
	float							m_Radius;

	int								m_level;
	int								m_Triangles;
};

